{#{% if categories %}#}
{#<div class="">#}
  {#<nav id="menu" class="navbar">#}
    {#<div class="navbar-header"><span id="category" class="visible-xs">{{ text_category }}</span>#}
      {#<button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>#}
    {#</div>#}
    {#<div class="collapse navbar-collapse navbar-ex1-collapse">#}
      {#<ul class="nav navbar-nav">#}
        {% for category in categories %}
            {#{% if category.children %}#}
            {#<li class="dropdown"><a href="{{ category.href }}" class="dropdown-toggle" data-toggle="dropdown">{{ category.name }}</a>#}
            {#<div class="dropdown-menu">#}
            {#<div class="dropdown-inner"> {% for children in category.children|batch(category.children|length / category.column|round(1, 'ceil')) %}#}
            {#<ul class="list-unstyled">#}
            {#{% for child in children %}#}
            {#<li><a href="{{ child.href }}">{{ child.name }}</a></li>#}
            {#{% endfor %}#}
            {#</ul>#}
            {#{% endfor %}</div>#}
            {#<a href="{{ category.href }}" class="see-all">{{ text_all }} {{ category.name }}</a> </div>#}
            {#</li>#}
            {#{% else %}#}
          <li class="left-menu-cate"><a href="{{ category.href }}">{{ category.name }}</a></li>
          <li class="home-cate-img"><a href="{{ category.href }}"><img src="{{ category.image }}"
                                                                       alt="{{ category.name }}"></a></li>
            {#{% endif %}#}
        {% endfor %}
      {#</ul>#}
    {#</div>#}
  {#</nav>#}
{#</div>#}
{#{% endif %}#}
<script>
    for (var i = $('.cate .home-cate-img').length-1; i > 0; i--) {
        if(i > 8){
            $('.cate .home-cate-img')[i].remove();
        }
    }
    var moreCate = '<li class="home-cate-img" onclick="toCate(this)"><a href="javascript:"><img src="catalog/view/theme/default/image/eew-150x168.jpg" alt="更多分類"></a></li>';
    $('.cate').append(moreCate);
    function toCate(_this) {
        $(_this).children('a').attr('href', $('.left-menu-cate:first a').attr('href'))
    }
</script>